/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2024.
* Description: dm functions headers for vims
*/

#ifndef DM_VIMS_H
#define DM_VIMS_H

#include <linux/fs.h>
#include <linux/device-mapper.h>
#include <linux/list.h>
#include <linux/moduleparam.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/hdreg.h>
#include <linux/completion.h>
#include <linux/kobject.h>
#include <linux/refcount.h>

/* Each segment include a series of device block */
struct dev_segment {
	struct list_head list;
	dev_t dvd;
	u64 start; /* bytes */
	u64 len;   /* bytes */
	char disk_name[DISK_NAME_LEN];
};

#ifdef CONFIG_VIMS_ENHANCE
int blk_path_check_retry(struct request *rq, blk_status_t error);
int dm_get_device_segment(dev_t dev, struct list_head *dev_list);
#else
static inline int blk_path_check_retry(struct request *rq, blk_status_t error) { return 0; };
static inline int dm_get_device_segment(dev_t dev, struct list_head *dev_list) { return -1; };
#endif /* CONFIG_VIMS_ENHANCE */
#endif /* DM_VIMS_H */
